<template>
    <scroll-view scroll-y class="content">
        <view v-for="item,index in data" @click="goUrl(item.id)">{{item.asset_mc}}({{item.asset_sn}})</view>
    </scroll-view>
</template>

<script>
    import API from '@/common/api.js';
    export default {
        data() {
            return {
                data: [],
                pzhAuthorization:uni.getStorageSync('pzhAuthorization')
            }
        },
        onShow() {

        },
        onLoad(options) {
            this.getData(options.id)
        },
        methods: {
            getData(xjgd_id) {
                API.selectGz({
                    start: 0,
                    length: 1000000,
                    xjgd_id,
                    pzhAuthorization: this.pzhAuthorization,
                }).then(res => {
                    if (res.resCode == 'success') {
                        uni.hideLoading()
                        this.data = res.datas
                    }
                })
            },
            goUrl(id) {
              API.selectGz({
                  flag: 'info',
                  isUpdate: 0,
                  id,
                  pzhAuthorization:this.pzhAuthorization ,
              }).then(res => {
                  if (res.resCode == 'success') {
                      uni.hideLoading()
                      let fault=res.datas[0]
                      fault.attachList=fault.attachList.replace(/id=/g,`pzhAuthorization=${this.pzhAuthorization}&id=`)
                       let  re = /<img.*?>/g;
                       let  arr = fault.attachList.match(re);
                       let files=[]
                       if(arr!=undefined&&arr.length){
                          arr.forEach(it=>{
                               files.push(it.match(/\ssrc=['"](.*?)['"]/)[1])
                          }) 
                       }
                       fault.files=files
                       uni.setStorage({
                           key: 'inspectFaultData',
                           data: JSON.stringify(fault)
                       });
                       uni.navigateTo({
                       	url: './inspectFault'
                       });
                  }
              })
                // uni.navigateTo({
                //     url: './camera?index=' + index
                // })
            }
        }
    }
</script>

<style lang="less" scoped>
    .content {
        font-size: 28rpx;
        height: 100vh;
        background-color: white;
        view {
            padding: 40rpx 40rpx 40rpx 0;
            margin-left: 40rpx;
            border-bottom: 2rpx solid #E9E9E9;
        }
    }
</style>
